//
//  LIUNetUnit.m
//  RxNet
//
//  Created by liuyu on 18/12/16.
//  Copyright (c) 2016 limit. All rights reserved.
//

#import "LIUNetUnit.h"

@implementation LIUNetUnit

+ (NSURLSessionTask *)get:(NSString *)url exec:(void (^)(NSData *, NSURLResponse *, NSError *))completionHandler {
    NSURLSession *session = [NSURLSession sharedSession];
    NSURL *aURL = [NSURL URLWithString:url];
    return [session dataTaskWithURL:aURL completionHandler:completionHandler];
}

+ (NSURLSessionTask *)post:(NSString *)url params:(NSString *)params exec:(void (^)(NSData *, NSURLResponse *, NSError *))completionHandler {
    NSURLSession *session = [NSURLSession sharedSession];
    NSURL *aURL = [NSURL URLWithString:url];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:aURL];
    request.HTTPMethod = @"POST";
    request.HTTPBody = [params dataUsingEncoding:NSUTF8StringEncoding];
    return [session dataTaskWithRequest:request completionHandler:completionHandler];
}
@end
